/**
 * 	 DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
 *   @author Colin Redmond
 *   Copyright (C) 2011 Colin Redmond
 *
 *   Licensed under the Apache License, Version 2.0 (the "License");
 *   you may not use this file except in compliance with the License.
 *   You may obtain a copy of the License at
 *
 *       http://www.apache.org/licenses/LICENSE-2.0
 *
 *   Unless required by applicable law or agreed to in writing, software
 *   distributed under the License is distributed on an "AS IS" BASIS,
 *   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 *   See the License for the specific language governing permissions and
 *   limitations under the License.
 */

package com.cred.industries.platform.dao;

import java.sql.Connection;
import java.sql.SQLException;
import java.util.List;

import com.cred.industries.platform.business.objects.CustomerBO;

public interface ICustomerDAO {

	/**
	 * inserts a customer into the DB
	 * @param cust customer BO we are going to insert
	 */
	void insert(CustomerBO cust);

	/**
	 * Creates a new customer using the CustomerBO
	 * the customerId will be updated with the new ID for the created customer
	 * takes in a connection , so we can use a transaction to create the customer
	 * @param connect the DB connection used to insert, assumed to be a session. Caller must manager
	 * @param cust customre BO to be inserted
	 */
	void insert(Connection connect, CustomerBO cust);

	/**
	 * updates a customer BO in the DB
	 * @param cust the customre BO to update
	 */
	void update(CustomerBO cust);

	/**
	 * updates and existing customer using the CustomerBO
	 * @param connect the DB connection used to insert, assumed to be a session. Caller must manager
	 * @param cust customer BO 
	 */
	void update(Connection connect, CustomerBO cust);

	/**
	 * returns the customer Business object from the Db
	 * @param custIdToFind the customer ID we are looking for the he DB
	 * @return
	 */
	CustomerBO findCustomerById(int custIdToFind);

	/**
	 * returns the customer Business object from the Db
	 * @param personaNameToFind persona name of the customer to find. Must me an exact match
	 * @return the customer BO matching the persona name
	 */
	CustomerBO findCustomerByPersonaName(String personaNameToFind);
	
	/**
	 * find a customer via an email address
	 * @param emailAddress email of customer we are looking for
	 * @return customer with matching email address
	 */
	CustomerBO findCustomerByEmail(String emailAddress);

	/**
	 * returns the customers Business object from the Db that partially match the persona name
	 * @param personaNameToFind persona name of the customer to find.
	 * @param setStart after how many found customers to get, ie get the 25th plus customers
	 * @param setSize the number of customers to get
	 * @return
	 */
	List<CustomerBO> findCustomersByPersonaName(String personaNameToFind, int setStart, int setSize);

	/**
	 * returns if a customer exists given a persona name
	 * @param personaName persona name of the customer to find.
	 * @return true if a customer with this persona name already exists
	 * @throws SQLException
	 */
	boolean doesCustomerExist(String personaName)
			throws SQLException;

}